#include <iostream>
#include <vector>
using namespace std;
///-----------------------------------------------------------------------------
typedef struct row_t{
	int col1;
	int col2;
}follow_row;

	vector<follow_row> followTable;
	vector<follow_row>::iterator it;

	void insertFollow(int stm1, int stm2)
	{
		follow_row newRow;
		newRow.col1 = stm1;
		newRow.col2 = stm2;
		followTable.push_back(newRow);

	}
	int findFollows(int stm){
		for (it=followTable.begin(); it<followTable.end(); it++){
			if(((follow_row)*it).col2 == stm){
				return ((follow_row)*it).col1;
			}
		}
		return -1;
	}

	int findFollowed(int stm){
		for (it=followTable.begin(); it<followTable.end(); it++){
			if(((follow_row)*it).col1 == stm){
				return ((follow_row)*it).col2;
			}
		}
		return -1;
	}
	bool isFollowed(int stm1,int stm2){
		for (it=followTable.begin(); it<followTable.end(); it++){
			if((((follow_row)*it).col1 == stm1) && (((follow_row)*it).col2 == stm2)){
				return 1;
			}
		}
		return 0;
	}

///-------------------------------------------------------------------------------------------------------



	typedef struct modify_stmt_row_t{
		int stmtNo;
		int varIndex;
		string DE;
	} modify_stmt_row;

	typedef struct modify_proc_row_t{
		int procIndex;
		int varIndex;
	} modify_proc_row;


		static vector<modify_stmt_row> ModifyStmtTable;
		static vector<modify_proc_row> ModifyProcTable;

	int insertModifyStmt(int stmtNo, int varIndex, string DE)
	{
		modify_stmt_row temp_row;

		for (unsigned i =0; i<ModifyStmtTable.size(); i++)
		{
			temp_row = ModifyStmtTable.at(i);
			if (temp_row.stmtNo == stmtNo)
			{
				cout<< "The stmt number is already in the ModifyTable";
				return -1;
			}
		}

		modify_stmt_row new_row;
		new_row.stmtNo = stmtNo;
		new_row.varIndex = varIndex;
		new_row.DE = DE;
		ModifyStmtTable.push_back(new_row);
		return 1;
	}

	int insertModifyProc(int procIndex, int varIndex)
	{
		modify_proc_row temp_row;

		for (unsigned i =0; i<ModifyProcTable.size(); i++)
		{
			temp_row = ModifyProcTable.at(i);
			if (temp_row.procIndex == procIndex && temp_row.varIndex == varIndex)
			{
				cout<< "The modify relationship is already in the ModifyTable"<<"\n";
				return -1;
			}
		}

		modify_proc_row new_row;
		new_row.procIndex = procIndex;
		new_row.varIndex = varIndex;
		ModifyProcTable.push_back(new_row);
		return 1;

	}

	int getModified(int stmtNo)
	{
		modify_stmt_row temp_row;

		for (unsigned i =0; i<ModifyStmtTable.size(); i++)
		{
			temp_row = ModifyStmtTable.at(i);
			if (temp_row.stmtNo == stmtNo)
			{
				return temp_row.varIndex;
			}
		}

		return -1;
	}

	vector<int> getModifiedList(int varIndex, string DE)
	{
		modify_stmt_row temp_row;
		vector<int> modifiedList;

		for (unsigned i =0; i<ModifyStmtTable.size(); i++)
		{
			temp_row = ModifyStmtTable.at(i);
			if (temp_row.varIndex == varIndex && temp_row.DE.compare(DE)==0)
			{
				modifiedList.push_back(temp_row.stmtNo);
			}
		}

		return modifiedList;
	}
    /// a variable modified in which stmts desipte the stmt'de type
    /// a variable modified by which procedure?



int main()
{
    /*
    for(int i=0;i<100;i++){
        insertFollow(i,i*100);
    }
    for(int i=0;i<100;i++){
        //cout<<findFollows(i*100)<<"\n";
        cout<<findFollowed(i)<<"\n";
        //cout<<isFollowed(i,i*100);
    }  */

    //insertModifyProc(1,3);
    insertModifyStmt(10,2,"bla");
    //insertModifyProc(1,2);
    insertModifyStmt(11,2,"bla");
    //insertModifyStmt(10,3,"");
    //insertModifyStmt(10,2,"else");
    //cout<<getModified(10);
    vector<int> a = getModifiedList(2,"");
    for(unsigned int i=0;i<a.size();i++){
        cout<<a.at(i)<<" ";
    }
    //cout << "Hello world!" << endl;
    return 0;
}
